#pragma once
#ifndef __LOG_H__
#define __LOG_H__

typedef enum {
    LOG_LEVEL_NONE = 0,
    LOG_LEVEL_ERR = 1,
    LOG_LEVEL_HIT = LOG_LEVEL_ERR,
    LOG_LEVEL_WARN = 2,
    LOG_LEVEL_INFO = 3,
    LOG_LEVEL_DBG = 4,
    LOG_LEVEL_CNT
} log_level_t;

typedef enum {
    LOG_COLOR_NONE,
    LOG_COLOR_RED,
    LOG_COLOR_GREEN,
    LOG_COLOR_YELLOW,
    LOG_COLOR_BLUE
} log_color_t;

#define LOG_INFO(fmt, args, ...)   \
    log_general((char *)__FILE__, (char *)__FUNCTION__, __LINE__, LOG_LEVEL_INFO, LOG_COLOR_NONE, (char *)"IFO", (char *)fmt, ##args)

#define LOG_WARN(fmt, args, ...)   \
    log_general((char *)__FILE__, (char *)__FUNCTION__, __LINE__, LOG_LEVEL_WARN, LOG_COLOR_YELLOW, (char *)"WRN", (char *)fmt, ##args)


#define LOG_ERR(fmt, args,...)   \
    log_general((char *)__FILE__, (char *)__FUNCTION__, __LINE__, LOG_LEVEL_ERR, LOG_COLOR_RED,    (char *)"ERR", (char *)fmt, ##args)

#define LOG_DBG(fmt, args, ...)   \
    log_general((char *)__FILE__, (char *)__FUNCTION__, __LINE__, LOG_LEVEL_DBG, LOG_COLOR_NONE, (char *)"DBG", (char *)fmt, ##args)

#define LOG_HIT(fmt, args, ...)   \
    log_general((char *)__FILE__, (char *)__FUNCTION__, __LINE__, LOG_LEVEL_HIT, LOG_COLOR_GREEN, (char *)"HIT", (char *)fmt, ##args)

extern void log_general(char* long_file, char* func, int line, log_level_t level, log_color_t color,
    char* ind, char* fmt, ...);// __attribute__((format(printf, 7, 8)));  //zwj revise

extern void log_init(log_level_t level, int color);
extern void log_set_level(log_level_t level);
extern void log_set_color(int color);
#endif

